package com.yiyuan.system.dao.impl;

import java.util.List;

import org.hibernate.Query;
import org.hibernate.Session;
import org.springframework.stereotype.Repository;

import com.yiyuan.common.base.BaseDao;
import com.yiyuan.system.dao.IUserRoleDao;
import com.yiyuan.system.model.UserRole;

@Repository("userRoleDao")
public class UserRoleDaoHbImpl extends BaseDao implements IUserRoleDao {
	public void add(UserRole userRole) {
		this.getHibernateTemplate().save(userRole);
	}

	@SuppressWarnings("unchecked")
	public List<UserRole> findListByUserId(Integer userId) {
		Session session = this.getSession();
		Query query = session.createQuery("from UserRole where userId=:userId");
		query.setInteger("userId", userId);
		List<UserRole> list = query.list();
		return list;
	}

	public void delete(UserRole userRole) {
		this.getHibernateTemplate().delete(userRole);
	}
}
